package pers.cfeng.server.versionManage;

import pers.cfeng.server.dataManage.DataManager;
import pers.cfeng.server.txManage.TransactionManager;

/**
 * 版本锁控制高层接口， 提供了读取read、 insert插入、delete删除以及事务的方法
 * 主要就是调用dm和tm层进行实现
 */

public interface VersionManager {
    byte[] read(long tid, long uid) throws Exception;
    long insert(long tid, byte[] data) throws Exception;
    boolean delete(long tid, long uid) throws Exception;

    long begin(int level);
    void commit(long tid) throws Exception;
    void rollback(long tid);

    public static VersionManager newVersionManager(TransactionManager tm, DataManager dm) {
        return new VersionManagerImpl(tm, dm);
    }
}
